<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'basic';
$return=array();
if($_RQ['op']=='basic'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$this->plugin_setting('setting',$postdata);
		exi('设置成功');
	}
	$footernav = array(
			array('title'=>'代理中心','icon'=>'icon-shouye','color'=>'#cc99ff','action'=>'jy_merch3fee/index/','image'=>'../addons/jy_weishop/resource/images/jy_weishoparticle.png'),
			array('title'=>'分红','icon'=>'icon-caifua','color'=>'#66cc99','action'=>'jy_merch3fee/commission/','image'=>'../addons/jy_weishop/resource/images/jy_fenleimsg.png'),
			array('title'=>'团订单','icon'=>'icon-manageorder','color'=>'#ff9933','action'=>'jy_merch3fee/order/','image'=>'../addons/jy_weishop/resource/images/jy_fenleimsg.png'),
			array('title'=>'我的团','icon'=>'icon-paihao0','color'=>'#66cc66','action'=>'jy_merch3fee/down/','image'=>'../addons/jy_weishop/resource/images/jy_fenleimsg.png'),
	);
	$return['item']=$this->plugin_setting('setting');
	$return['item']['footernav'] = !empty($return['item']['footernav']) ? $return['item']['footernav'] : $footernav;
	if($this->plugin_exists('jy_teamfee')){
		$return['item']['jy_teamfee']=1;
	}
	$htmls=array(
		'type'=>'edit',
		'desc'=>'参数设置',
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'基础设置',
				'list'=>array(
					array('type'=>'switch','title'=>'是否启用？','name'=>'isopen'),
					array('type'=>'string','title'=>'页面标题','name'=>'title'),
					array('type'=>'string','title'=>'《默认等级》重命名','name'=>'diylevelname'),
					array('type'=>'radio','title'=>'成为默认等级条件','name'=>'become','options'=>'become'),
					array('type'=>'radio','title'=>'成为默认等级指标','name'=>'team_tiaojian','options'=>'team_tiaojians','show'=>array('become'=>'3'),'help'=>''),
					array('type'=>'unitstring','unit'=>'元','title'=>'自购单笔金额满','name'=>'tiaojian0','show'=>array('team_tiaojian'=>'0')),
					array('type'=>'unitstring','unit'=>'元','title'=>'自购订单总金额满','name'=>'tiaojian1','show'=>array('team_tiaojian'=>'1')),
					array('type'=>'unitstring','unit'=>'个','title'=>'自购订单数满','name'=>'tiaojian2','show'=>array('team_tiaojian'=>2)),
					array('type'=>'unitstring','unit'=>'元','title'=>'获得总分销佣金满','name'=>'tiaojian3','show'=>array('team_tiaojian'=>3)),
					array('type'=>'unitstring','unit'=>'人','title'=>'下线总人数满','name'=>'tiaojian4','show'=>array('team_tiaojian'=>4)),
					array('type'=>'unitstring','unit'=>'人','title'=>'一级下线总人数满','name'=>'tiaojian5','show'=>array('team_tiaojian'=>5)),
					array('type'=>'unitstring','unit'=>'人','title'=>'下线分销商满','name'=>'tiaojian6','show'=>array('team_tiaojian'=>6)),
					array('type'=>'unitstring','unit'=>'人','title'=>'一级分销商满','name'=>'tiaojian7','show'=>array('team_tiaojian'=>7)),
					array('type'=>'unitstring','unit'=>'元','title'=>'分销订单总金额满','name'=>'tiaojian8','show'=>array('team_tiaojian'=>8)),
					array('type'=>'unitstring','unit'=>'个','title'=>'分销订单总数满','name'=>'tiaojian9','show'=>array('team_tiaojian'=>9)),
					array('type'=>'unitstring','unit'=>'元','title'=>'一级分销订单总金额满','name'=>'tiaojian10','show'=>array('team_tiaojian'=>10)),
					array('type'=>'unitstring','unit'=>'个','title'=>'一级分销订单总数满','name'=>'tiaojian11','show'=>array('team_tiaojian'=>11)),
					array('type'=>'choose_many','title'=>'指定商品','name'=>'become_goods','action'=>'jy_weishop/goods.get_goods/many/','show'=>array('team_tiaojian'=>12)),
					array('type'=>'checkbox','title'=>'代理升级考核指标','name'=>'level_up_types','options'=>'leveltype','help'=>'《推荐同等级个数》：是指推荐了同等级的团个数，比如等级分为，A,B,C,D,E。A是预选团长，E是最高团长。我现在是C等级，想上级D等级，需要我的下级里面有C等级**个'),
					array('type'=>'unitstring','unit'=>'人','title'=>'需贡献N个直推给老板？','name'=>'zhu_num'),
					array('type'=>'select','options'=>'levels','title'=>'指定《老板》等级？','name'=>'boss_levelid'),
					array('type'=>'switch','title'=>'是否需要审核','name'=>'isshenhe','isradio'=>1),
					array('type'=>'switch','title'=>'是否需要完善资料','name'=>'isinfo','isradio'=>1),
					array('type'=>'switch','title'=>'前端是否关闭【平级出局感恩奖】','name'=>'isnofee5','isradio'=>1,'help'=>'关闭后后台不计佣金，前端不显示'),
					array('type'=>'switch','title'=>'前端是否支持【团队级差分红】？','name'=>'isteamfee','isradio'=>1,'show'=>array('jy_teamfee'=>'1')),
					array('type'=>'link','from'=>'action','title'=>'商城链接','name'=>'shop_action','help'=>'队员中心的商城链接，不填则默认jy_areashop/index/！'),
					array('type'=>'link','from'=>'action','title'=>'商户商城链接','name'=>'mshop_action','help'=>'队员中心的商城链接，不填则默认jy_areashop/merchshop/！'),
					array('type'=>'string','title'=>'代理分享二维码说明','name'=>'share_help'),
					array('type'=>'string','title'=>'代理分享标题','name'=>'teamshare_title'),
					array('type'=>'string','title'=>'代理分享描述','name'=>'teamshare_desc'),
					array('type'=>'richtext','title'=>'代理须知','name'=>'team_xieyi'),
				)
			),
			array(
				'title'=>'结算设置',
				'list'=>array(
					array('type'=>'switch','title'=>'下单即可结算','name'=>'is_jiesuan','help'=>'不用等完成订单，就可以结算！'),
					array('type'=>'switch','title'=>'感恩奖结算为金币?','name'=>'fee_to3','isradio'=>1,'help'=>''),
					array('type'=>'unitstring','title'=>'感恩奖每月结算超过【N】元','unit'=>'元','name'=>'fee_to3max','help'=>''),
					array('type'=>'string_two','title'=>'感恩奖每月结算超过上面设置后','title1'=>'【%】结算为元宝','unit1'=>'%','name1'=>'fee_to34','title2'=>'【%】结算为金币','unit2'=>'%','name2'=>'fee_to33','help'=>''),
					array('type'=>'checkbox','title'=>'支持的提现方式','name'=>'withdrawtype','options'=>'withdraw'),
					array('type'=>'string','title'=>'结算额度（元）','name'=>'balance_fee'),
					array('type'=>'string','title'=>'分红打款手续费（%）','name'=>'balance_per'),
					array('name'=>'commissiontype','title'=>'佣金金额计算方式','type'=>'radio','help'=>'第一种：按商品实际成交价×百分比；第二种：按商品利润：【实际成交价-成本】×百分比；','options'=>'commissiontype'),
					array('type'=>'string','title'=>'免手续费提现区间开始金额','name'=>'balance_money_start'),
					array('type'=>'string','title'=>'免手续费提现区间结束金额','name'=>'balance_money_end','help'=>'当提现手续费金额在此区间内时,不扣除提现手续费. 结束金额 必须大于 开始金额才能生效'),
					array('type'=>'string','title'=>'结算天数','name'=>'balance_day','help'=>'当订单完成后的n天后，订单才能申请结算,设置0或空，订单完成就可以结算'),
				),
			),
			array(
				'title'=>'贡献值',
				'list'=>array(
					array('type'=>'switch','title'=>'是否开启？','name'=>'gongfee_open','isradio'=>1),
				),
			),
			array(
				'title'=>'能量值',
				'list'=>array(
					array('type'=>'tip','title'=>'我的设置-支付参数设置-其它虚拟币-备用金[命名能量值]
					</br>1、会员怎么获得能量值：启用能量值后，在商品-营销中设置赠送能量值数量，会员自购有赠送能量值的商品即可获得能量值;
					</br>2、合计的能量值可1:1提现；
					</br>3、合计的能量值不提现，可每天增值；
					</br>4、能量值每天增值说明：前提举例：商城有10个会员，每个会员有100个能量值，合计1000个能量值；昨日总增值100个。100元÷1000个能量值=0.1个能量值；能量值个人增值计算公式：0.1个能量值×个人100个能量值=10个能量值；
					'),
					array('type'=>'switch','title'=>'是否开启？','name'=>'nengfee_open','isradio'=>1,'help'=>'注：启用后前端才展示能量值科目'),
					array('type'=>'unitstring','title'=>'能量值增值池%','unit'=>'%','name'=>'nengfee_rate','help'=>'设置商城每笔订单分红百分之几进入能量值增值池，（支持商品独立增值设置）'),
					array('type'=>'unitstring','title'=>'能量值每日额外增值','unit'=>'个','name'=>'nengfee_daynum','help'=>'每日额外，增值N个到增值池'),
					array('type'=>'checkbox','title'=>'支持的提现方式','name'=>'withdrawtype2','options'=>'withdraw2'),
					array('type'=>'string','title'=>'结算额度（元）','name'=>'balance_fee2'),
					array('type'=>'string','title'=>'分红打款手续费（%）','name'=>'balance_per2'),
				),
			),
			array(
							'title'=>'底部导航',
							'list'=>array(
								array('type'=>'array','name'=>'footernav','add_tip'=>'添加一个底部导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),
										array('type'=>'string','name'=>'action','title'=>'导航链接'),
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'导航链接'),
									)
								),
							)
			),
			array(
					'title'=>'自定义文字',
					'list'=>array(
						array('type'=>'text','name'=>'agent_desc','title'=>'成为代理的条件提示','help'=>'默认是按成为预选代理指标，来显示的！'),
					)
			),
		)
	);
	$params=array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$_SESSION['onemerchid']);
    $orderby='level asc';
	$return['levels']=$this->getall('level',$params,array('id','title'),'id',$orderby);
	$return['jiefee_type']=array('到达等级自动解冻','推荐指定等级人数解冻');
	$return['yesno']=array('不能','能');
	$return['daili_file']=$this->daili_file;
	$return['feeti_type']=$this->feeti_type;
	$return['team_tiaojians']=$this->team_tiaojians;
	$return['leveltype']=$this->level_up_types;
	$return['agent_types']=$this->agent_types;
	$return['withdraw']=$this->pay_types;
	$return['commissiontype']=$this->commission_types;
	$return['become']=array('0'=>'无条件','1'=>'后台指定','2'=>'提交申请','3'=>'按条件');
	$return['withdraw2']=array('提现到微信钱包','提现到支付宝','提现到银行卡','提现余额');
	$return['level']=$this->level_types;
	$return['htmls']=$htmls;
	exi($return);
}


